<h2> Subscriber</h2>
<?php
    $this->headTitle('Subscriber');
    $this->headScript()->appendFile('/js/BizSense/Crud.js');
    $acl = $this->acl;    
?>

<?php if  ($acl->isAllowed($this->currentUser, 'access newsletter pages')): ?>
<a href="<?php echo $this->url(array(
    'module'    =>'newsletter', 
    'controller'=>'index',
    'action'    =>'index'
    )
  , null, true); ?>">Newsletter</a>
  |
<?php endif; ?>

<?php if  ($acl->isAllowed($this->currentUser, 'access newsletter pages')): ?>
<a href="<?php echo $this->url(array(
    'module'    =>'newsletter', 
    'controller'=>'subscriber',
    'action'    =>'create'
    )
  , null, true); ?>">Create Subscriber</a>
<?php endif; ?>

<fieldset class="fieldset_properties">
    <legend>
        <img src="/images/design/search.png"></li>
                     Search
     </legend>
        <?php echo $this->form; ?>
</fieldset>

<b>Total subscribers : <?php echo $this->paginator->getAdapter()->count(); ?></b>
<?php if (count($this->paginator)): ?>
<table class="data_table">
    <tr>
        <th>Name <?php echo $this->sortButtons("firstName"); ?></th>
        <th>E-mail<?php echo $this->sortButtons("email"); ?></th>
        <th>Format</th>
        <th>Status</th>
       <th>Action</th>
    </tr>
<?php foreach ($this->paginator as $item): ?>

    <tr>
        <td><?php echo $this->escape($item['first_name'])." ".
                       $this->escape($item['middle_name'])." ".
                       $this->escape($item['last_name']); ?></td>
        <td><?php echo $this->escape($item['email']); ?></td>
        <td><?php 
                if($item['format'] == Core_Model_Newsletter_Subscriber::FORMAT_HTML) {
                    echo "HTML";
                } else {
                    echo "Text";
                }
        
            ?>
        </td>
        <td><?php 
                if ($item['status'] == Core_Model_Newsletter_Subscriber::CONFIRMED) {
                        echo "Confirmed";
                }
                else if ($item['status'] == Core_Model_Newsletter_Subscriber::UNCONFIRMED) {
                        echo "Unconfirmed";
                }  
                else if ($item['status'] == Core_Model_Newsletter_Subscriber::ACTIVE) {
                        echo "Active";
                } 
                else if ($item['status'] == Core_Model_Newsletter_Subscriber::BLOCKED) {
                        echo "Blocked";
                } 
             ?>
        </td>
        <td>
            <a href="<?php echo $this->url(
                array
                (
                    'module' => 'newsletter',
                    'controller' => 'subscriber',
                    'action' => 'edit',
                    'subscriber_id' => $item['subscriber_id']
                ), 'default', true
            ); ?>">Edit</a>
            
            <a href="<?php echo $this->url(
                array
                (
                    'module' => 'newsletter',
                    'controller' => 'subscriber',
                    'action' => 'viewdetails',
                    'subscriber_id' => $item['subscriber_id']
                ), 'default', true
            ); ?>">Details</a>
            
            <?php 
                $deleteUrl = $this->url(
                    array(
                        'module' => 'newsletter',
                        'controller' => 'subscriber',
                        'action' => 'delete',
                        'subscriber_id' =>$this->escape($item['subscriber_id'])
                    )
                );
                echo $this->deleteButton($deleteUrl); 
             ?>
         </td>
    </tr>
<?php endforeach; ?>
</table>
<?php endif; ?>

<?php
    if ($this->wasSearched and !count($this->paginator)) {
        echo "<br />There are no records matching the search criteria";
    }
?>

<div class="pagination">
<?php echo $this->paginationControl($this->paginator, 'Sliding', 'search.phtml'); ?>
</div>
<div class="div_clear"></div>

